<?php

require_once( ORM_DIR.'/extractors/Extractor.php' );

class SwitchByField implements Extractor {
	
	private $_fieldName;
	private $_extractors;
	
	public function __construct( $fieldName, array $extractors ) {
		$this->_fieldName = $fieldName;
		$this->_extractors = $extractors;
	}
	
	public function & get( & $storage, array & $fields ) {
		$this->_extractors[ $fields[ $this->_fieldName ] ]->get( $storage, $fields );
	}
	
	public function set( & $storage, array & $fields, $value ) {
		$this->_extractors[ $fields[ $this->_fieldName ] ]->set( $storage, $fields, $value );
	}
}

?>